#include 
 
#include 
 
 
struct book
 
{ int num;
 
char name[50];
 
char publish[40];
 
struct
 
{ int year;
 
int month;
 
}day;
 
char borrow;
 
}books[5];
 
main()
 
{ char name[50];
 
int i,num;
 
int flag=0;
 
for(
i=0;i<2;i++)
 
{ printf("input book's num,name,publish,day:
\
n");
 
scanf("%d",&books[i].num);
 
scanf("%s
\
n",books[i].name);
 
gets(books[i].publish);
 
scanf("%d%d",&books[i].day.year,&books[i].day.month);
books[i].borrow='n';
 
}
 
printf("
----------------------------
-----------
\
n");
 
printf("output the book's information:
\
n");
 
printf(" num name publish publishday borrow:
\
n");
 
for(i=0;i<2;i++)
printf("% 
-
10d%
-
16s%
-
12s%6d,%d%9c
\
n",books[i].num,books[i].name,books[i].publish,books[i].d
ay.year,books[i].day.month,books[i].b
orrow);
 
printf("
------------------------------------------
\
n");
 
printf("Now you can input your book name:
\
n");
 
scanf("%s",name);
 
for(i=0;i<2;i++)
 
{
 
if(strcmp(books[i].name,name)==0)
 
{ flag=1;
 
if(books[i].borrow=='n')
 
{ books[i].borrow='y';
 
printf("success!
");
 
}
 
else printf("The book has been borrowed.You can't borrow it.");
}
 
}
 
if(flag==0)
 
printf("We can't find this book.");
 
}

